#!/usr/bin/env python3
# -*-coding: utf-8-*-
# 二分法查找数值


def binary_search(lst, target):

    _len = len(lst)
    if _len == 0:
        return 'lst为空'
    if _len == 1:
        if target == lst[0]:
            return True
        else:
            return False
    if target == lst[_len // 2]:
        return True
    elif target > lst[_len // 2]:
        return binary_search(lst[_len//2+1: ], target)
    else:
        return binary_search(lst[:_len//2], target)



if __name__ == '__main__':

    lst = [n for n in range(50) if n%2]
    # lst = [21, 23]
    t = 20
    print(binary_search(lst, t))



